package aspectualacme.util;

import java.io.File;

import javax.annotation.Generated;
import javax.swing.JOptionPane;

import org.AcmeStudio.Parser.ParseException;

import teste.actions.Generate;

//import generator.generate.transformations.AspectualAcme;

//import org.AcmeStudio.Util.ModelToCode;





public class AspectualAcmeGeneratorCode {
	
	public static void generatorCode(String modelPath,String generatePath){
		//generatePath = "E:\\projetos\\monografia\\integracao\\CodigoGerado\\src";
		//modelPath ="E:\\projetos\\monografia\\integracao\\ExemploAspectualAcme\\System.aspectualacme";
		System.out.println("cheguei aqui");
		
		try {
			String caminhoArquivo="/lib/AspectualAcme.emt";
			File arquivo = new File(caminhoArquivo);
			if(arquivo.exists()){
				System.out.println(arquivo.getAbsolutePath());
				System.out.println("m "+modelPath);
				System.out.println("g "+generatePath);
			}
			Generate gen = new Generate();
			gen.gen(modelPath, generatePath, caminhoArquivo);
			
			
			System.out.println("Sai daqui");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public static void Analiser(String acmeFile){
		try {
			File ar = new File(acmeFile);
			if(ar.exists()){
				System.out.println(acmeFile);
				org.AcmeStudio.Demonstracao.Analiser.Parser(acmeFile);
				StringBuffer bf = org.AcmeStudio.gui.Main.getErros();
				System.out.println(bf.toString());
				JOptionPane.showMessageDialog(null, bf.toString(),"Errors List", JOptionPane.ERROR_MESSAGE);
			}
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch(NullPointerException npe){
			npe.printStackTrace();
		}
		
	}

}
